package com.speedchina.permission.thread;

import lombok.extern.slf4j.Slf4j;

import java.util.concurrent.ThreadFactory;
import java.util.concurrent.atomic.AtomicInteger;

/**
 * @author Winter
 */
@Slf4j
public class SysLogThreadFactory implements ThreadFactory {
    String threadName = "syslog-thread-";
    private final AtomicInteger mThreadNum = new AtomicInteger(1);
    public SysLogThreadFactory(String name) {
        this.threadName=name;
    }
    public SysLogThreadFactory(){

    }
    @Override
    public Thread newThread(Runnable r) {
        Thread t = new Thread(r, threadName + mThreadNum.getAndIncrement());
        log.debug(t.getName() + " has been created");
        return t;
    }
}
